package coreservlets;

import java.util.*;

public class PurchaseBean {
  private String[] cheapItems =
    { "Gum", "Yo-yo", "Pencil" };
  private ArrayList mediumItems =
    new ArrayList();
  private HashMap valuableItems =
    new HashMap();
  private boolean isEverythingOK = true;

  public PurchaseBean() {
    mediumItems.add("iPod");
    mediumItems.add("GameBoy");
    mediumItems.add("Cell Phone");
    valuableItems.put("low", "Lamborghini");
    valuableItems.put("medium", "Yacht");
    valuableItems.put("high", "Chalet");
  }

  public String[] getCheapItems() {
    return(cheapItems);
  }

  public List getMediumItems() {
    return(mediumItems);
  }

  public Map getValuableItems() {
    return(valuableItems);
  }

  public String purchaseItems() {
    isEverythingOK = Utils.doBusinessLogic(this);
    isEverythingOK = Utils.doDataAccessLogic(this);
    if (isEverythingOK) {
      return("success");
    } else {
      return("failure");
    }
  }
}